package com.sneaker.shower.mapstruct;

import com.sneaker.shower.entity.domain.order.discount.CouponDO;
import com.sneaker.shower.entity.dto.coupon.CouponRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author Hechangjian
 * @version 1.0
 * @className CouponMapstruct
 * @date 2019/11/26 14:46
 * @description
 * @program bath
 */
@Mapper
public interface CouponMapStruct {

    CouponMapStruct INSTANCE = Mappers.getMapper(CouponMapStruct.class);

    List<CouponRespDTO> doList2DTOList(List<CouponDO> doList);

    @Mappings({
            @Mapping(target = "typeName", expression = "java(com.sneaker.shower.entity.enums.CouponTypeEnums.getNameByCode(couponDO.getType()))"),
            @Mapping(target = "expiredTimeStr", expression = "java(couponDO.getExpiredTime().format(java.time.format.DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\")))")
    })
    CouponRespDTO do2RespDTO(CouponDO couponDO);
}
